package com.ztom.v2;

/**
 * @author ZhangTao
 */
public class Code81ClimbingStairs {

    public int climbStairs(int n) {
        if (n == 0) {
            return 0;
        }
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        int prepre = 1;
        int pre = 2;
        for (int i = 3; i <= n; i++) {
            // 当前台阶可以由前一个台阶或前两个台阶到达
            int res = pre + prepre;
            prepre = pre;
            pre = res;
        }
        return pre;
    }
}
